package com.bjtang.book;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @类名  Swagger2.java
* @说明 
* @作者  唐帮杰
* @时间  2019年6月22日下午2:57:58
*/
@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bjtang.book.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("book RESTful APIs")
                .description("完成闲置图书交易系统网站后台RESTful APIs接口开发")
                .termsOfServiceUrl("https://www.bjtang.com/fuwutiaokuan")
               .contact(new Contact("@bjtang", "https://www.bjtang.com", "bjtang@bjtang.com"))
                .version("0.1")
                .build();
    }

}